cmake_minimum_required(VERSION 3.16)

project(CNC_Double_Head_Saws_Horizontal VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt6 REQUIRED COMPONENTS Quick SerialBus Sql NetWork SerialPort Widgets)
find_package(Qt6 REQUIRED COMPONENTS Core)



qt_standard_project_setup(REQUIRES 6.8)

qt_add_executable(CNC_Saws_Horizontal
    main.cpp    
    Elements.qrc
    Windows.qrc
    Images.qrc
)


target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)
target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)

# target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core Qt6::SerialBus)
# target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)

# set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "QML import paths" FORCE)

qt_add_qml_module(CNC_Saws_Horizontal
    URI CNC_Double_Head_Saws_Horizontal
    VERSION 1.0
    QML_FILES
        Main.qml
        A_Button.qml
        A_ImageButton.qml
        A_SwitchButton.qml
        A_NumberInput.qml
        A_NumberKeyboard.qml
        A_ComboBox.qml
        A_Textinput.qml
        Alarm_Area.qml

        Manual_Process_Window.qml
        Normal_ManualProcess.qml
        ExtraLong_ManualProcess.qml
        ExtraShort_ManualProcess.qml
        Corner_ManualProcess.qml
        Handle_Location_ManualProcess.qml

        Material_List_Window.qml
        Local_Material_List_ListWindow.qml
        QR_Code_List_ListWindow.qml
        Online_Material_List_ListWindow.qml
        U_Disk_Material_List_ListWindow.qml

        Manual_Deubg_Window.qml
        Manipulation_DebugWindow.qml
        IO_Monitor_DebugWindow.qml
        Printer_Debug_Window.qml

        Parameter_Setting_Window.qml
        MechineParameter_ParameterWindow.qml
        ServoParameter_ParameterWindow.qml
        BracketParameter_ParameterWindow.qml
        LocationCompensation_ParameterWindow.qml
        LocationCompensation_Page_1_ParameterWindow.qml
        LocationCompensation_Page_2_ParameterWindow.qml
        AnyLocationCompensation_ParameterWindow.qml
        ConnectParameter_ParameterWindow.qml

        ConfigSystemWindow.qml
        Config_ConfigWindow.qml
        Encrypt_ConfigWindow.qml

        SideBar.qml
        TopBar.qml
        MechineAngle.qml
        Warning_Message_Popup_Window.qml

    SOURCES appengine.h appengine.cpp
    SOURCES localconfig.h localconfig.cpp
    SOURCES modbuscontrol.h modbuscontrol.cpp
    SOURCES sqlitepool.h sqlitepool.cpp
    SOURCES languagecontrol.h languagecontrol.cpp
    SOURCES printercontrol.h printercontrol.cpp
    SOURCES usb_process_list_model.h usb_process_list_model.cpp
    SOURCES Mid_Struct.h
    SOURCES networkmanager.h networkmanager.cpp
    SOURCES online_process_list_model.h online_process_list_model.cpp
    SOURCES scannercontrol.h scannercontrol.cpp
    SOURCES Order_Process/order_process_manager.h Order_Process/order_process_manager.cpp
    SOURCES Order_Process/order_process_database.h Order_Process/order_process_database.cpp
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(CNC_Saws_Horizontal PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.CNC_Saws_Horizontal
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_link_libraries(CNC_Saws_Horizontal
    PRIVATE Qt6::Quick
    PRIVATE Qt6::SerialPort
    PRIVATE Qt6::SerialBus
    PRIVATE Qt6::Network
    PRIVATE Qt6::Sql
    PRIVATE Qt6::Widgets
)
target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)
target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)
target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)
target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)
target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)
target_link_libraries(CNC_Saws_Horizontal PRIVATE Qt6::Core)

include(GNUInstallDirs)
install(TARGETS CNC_Saws_Horizontal
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(WIN32)
    target_sources(CNC_Saws_Horizontal PRIVATE appIcon.rc)
    set_property(TARGET CNC_Saws_Horizontal PROPERTY WIN32_EXECUTABLE TRUE)
endif()
